package Views;

import Views.Base.BaseViewMain;
import Types.AccountType;
import java.util.ArrayList;

/**
 * the main user interface iin which all the gui data is displayed
 * @author Joshua
 */
public class ViewMain extends BaseViewMain {

    private static AccountType onlineUser = new AccountType();
    private static ViewMain instance;

    private ViewMain() {
        
    }

    public static ViewMain getInstance() {
        if(instance == null) {
            instance = new ViewMain();
        }
        return instance;
    }

    /**
     * gets the online user data
     * @return
     */
    public static AccountType getOnlineUser() {
        return onlineUser;
    }

    /**
     * sets the online user data
     * @param onlineUser
     */
    public static void setOnlineUser(AccountType onlineUser) {
        ViewMain.onlineUser = onlineUser;
    //loginPanel.updateUISuccess(onlineUser.getUsername());
    }

    public void updateCreateUser() {
        setCenterPanel(createUserPanel);
    }

    public void updateDeleteUser() {
        setCenterPanel(GUIFactory.makeViewDeleteUser());
        //setCenterPanel(deleteUserPanel);
    }

    public void updateDisplayFlights(ArrayList arr) {
        setCenterPanel(GUIFactory.makeViewFlights(arr));
    }

    public void updateMsg(String msg) {
        updatePanel.setText(msg);
        setCenterPanel(updatePanel);
    }
    
    public void updateLoginUser() {
        logoutPanel.setUserLabel(onlineUser.getUsername());
        setNorthPanel(logoutPanel);
        //setWestPanel(GUIFactory.makeViewUserBar());
        //setWestPanel(GUIFactory.makeViewManBar());
        setWestPanel(GUIFactory.makeViewAdmBar());
    }
    
    public void updateLogoutUser() {
        logoutPanel.setUserLabel("");
        setNorthPanel(northLoginPanel);
        setWestPanel(westGeneralPanel); 
        setCenterPanel(null);
    }
        
    public void updateEditFlight() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    
    void updateAddPromotion() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void updateBuyTicket() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void updateCreateManager() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void updateDeleteAirport(String [] str) {
        setCenterPanel(GUIFactory.makeViewDeleteAirport(str));
    }

    void updateDeleteFlight() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void updateDeleteManager() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void updateEditAirport(String [] str) {
        setCenterPanel(GUIFactory.makeViewEditAirport(str));
    }

    void updateEditManager() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    void updateMakeAirport() {
        setCenterPanel(GUIFactory.makeViewCreateAirport());
    }

    void updateMakeFlight() {
        throw new UnsupportedOperationException("Not yet implemented");
    }


}
